﻿using System;
using System.Windows.Data;
using System.Globalization;

namespace Samples.Radio.Helpers.Converters
{
    public class CaseConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var caseParameter = parameter as string;
            if (caseParameter == null || value==null) return value;
            switch (caseParameter.ToLower())
            {
                case "upper":
                    return value.ToString().ToUpper();
                case "lower":
                    return value.ToString().ToLower();
            }
            return value.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }

}